package com.yanqu.road.server.cmd.activity.share;

import com.yanqu.road.pb.activity.ShareProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.share.ShareModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_SHARE_GOODS_REWARD,desc = "")
public class ShareGoodsRewardCmd extends AbstractCommand {
    private int id;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        ShareProto.PatronsBeautyShareSuccessReqMsg req = ShareProto.PatronsBeautyShareSuccessReqMsg.parseFrom(packet.getBytes());
        id = req.getId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(ShareModule.class).shareGoods(id);
    }

    @Override
    public void sendData(GamePlayer player) {
        ShareProto.PatronsBeautyShareSuccessRespMsg.Builder resp = ShareProto.PatronsBeautyShareSuccessRespMsg.newBuilder();
        resp.setRet(ret);
        player.sendPacket(ClientProtocol.U_SHARE_GOODS_REWARD, resp);
    }
}
